@extends('main')

@section('tip', '查看博客内容')

@section('content')
<div class="row">
    <div class="col-md-9">
        <div class="row">
            <h2>{{ $post->title }}</h2>
            <hr>
            {!! $post->body !!}
            <hr>
            <p>
                <strong>标签:</strong>
                @foreach($post->tag as $tag)
                <span class="label label-default">{{ $tag->name }}</span>
                @endforeach
            </p>
        </div>
        <div class="row">
            <h4>评论:</h4>
            <hr>
        <table class="table">
            <thead>
                <tr>
                    <th>name</th>
                    <th>email</th>
                    <th>comment</th>
                    <th>option</th>
                </tr>
            </thead>
            <tbody>
                @foreach($post->comment as $comment)
                    <tr>
                        <td>{{ $comment->name }}</td>
                        <td>{{ $comment->email }}</td>
                        <td>{{ $comment->comment }}</td>
                        <td>
                        {!! Form::open(['route'=>['comment.destroy', $comment->id], 'method'=>'DELETE']) !!}
                        {!! Form::submit('删除', ['class'=>'btn btn-default btn-xs']) !!}
                        <a href="{{ route('comment.edit', $comment->id) }}" class="btn btn-default btn-xs">编辑</a>
                        {!! Form::close() !!}
                        </td>
                    </tr>                
                @endforeach
            </tbody>
        </table>
        </div>
    </div>

    <div class="col-md-3">
        <div class="well">
            <div class="row" style="padding-left:15px;">
                <dl>
                    <dt>创建日期:</dt>
                    <dd>{!! date('Y年m月d日 <\b\r> H时i分s秒', strtotime($post->created_at)) !!}</dd>
                </dl>
                <dl>
                    <dt>修改日期:</dt>
                    <dd>{!! date('Y年m月d日 <\b\r> H时i分s秒', strtotime($post->updated_at)) !!}</dd>
                </dl>
                <dl>
                    <dt>所属分类:</dt>
                    <dd>{{ $post->category->name }}</dd>
                </dl>
            </div>
            <hr>
            <div class="row">
                <div class="col-md-6">
                {!! Html::linkRoute('post.edit', '修改', $post->id, ['class'=>'btn btn-primary btn-block']) !!}
                </div>
                <div class="col-md-6">
                {!! Form::open(['route'=>['post.destroy', $post->id], 'method'=>'DELETE']) !!}
                {!! Form::submit('删除', ['class'=>'btn btn-danger btn-block']) !!}
                {!! Form::close() !!}
                </div>
            </div>
            <hr>
            <div class="row">
                <div class="col-md-12">
                    {!! Html::linkRoute('post.index', '查看所有博文', null, ['class'=>'btn btn-default btn-block']) !!}
                </div>
            </div>
            <hr>
            <div class="row">
                <div class="col-md-12">
                    <a href="{{ route('blog.show', $post->slug) }}" class="btn btn-default btn-block">{!! url($post->slug) !!}</a>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
